import java.util.Scanner;
import java.util.Arrays;
    public class Main {
        public static double avg(int[] array) {
            double sum = 0;
            int i = 0;
            for (i = 0; i < array.length; i++) {
                sum += array[i];
            }
            return sum / (i + 1);
        }

        public static void main1(String[] args) {
            int[] array = {1, 2, 3, 4, 5};
            System.out.println(avg(array));
        }

        public static double Sum(double[] array) {
            double sum = 0;
            for (int i = 0; i < array.length; i++) {
                sum += array[i];
            }
            return sum;
        }

        public static void main2(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            double[] array = new double[n];
            int i = 0;
            for (i = 0; i < array.length; i++) {
                array[i] = scanner.nextInt();
            }
            System.out.println(Sum(array));
        }

        public static void transform(int[] array) {
            int i = 0;
            for (i = 0; i < array.length; i++) {
                array[i] = 2 * array[i];
            }
        }

        public static void main3(String[] args) {
            int[] array = {1, 2, 3};
            transform(array);
            String str = Arrays.toString(array);
            System.out.println(str);
        }

        public static void print(int[] array) {
            int i = 0;
            for (i = 0; i < array.length; i++) {
                System.out.println(array[i]);
            }
        }

        public static void main4(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int[] array = new int[n];
            int i = 0;
            for (i = 0; i < array.length; i++) {
                array[i] = scanner.nextInt();
            }
            print(array);
        }

        public static void main5(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int[] array = new int[n];
            for (int i = 1; i <= array.length; i++) {
                array[i - 1] = i;
            }
        }

        public static void copyof(int[] array,int[] array1){
            int i = 0;
            for(i = 0;i<array1.length;i++){
                array[i] = array1[i];
            }
        }
        public static void main6(String[] args) {
            int[] array = {1,2,3,4,5};
            int[] array2 = new int[array.length];
            copyof(array2,array);
            System.out.println(Arrays.toString(array2));
        }

        public static String my_toString(int[] array){
            String str = "[";
            int i = 0;
            for(i = 0;i<array.length;i++){
                str+=array[i];
                if(i+1!=array.length){
                    str+=",";
                }
                else{
                    str+="]";
                }
            }
            return str;
        }

        public static void main7(String[] args) {
            int[] array = {1,2,3};
            System.out.println(my_toString(array));

        }

        public static void main8(String[] args) {
                Scanner scanner = new Scanner(System.in);
                String arr = scanner.nextLine();

                System.out.println();

        }

        public static int search(int[] array,int n,int num){
            int left = 0;
            int right = n-1;
            int mid = (left+right)/2;
            while(left<right){
                mid = (left+right)/2;
                if(array[mid]<num){
                    left = mid+1;
                }else if(array[mid]>num){
                    right = mid+1;
                }else
                    return mid;
            }
            return -1;
        }
        public static void main9(String[] args) {
            int[] array = {3,4,5,6,7,8,9};
            int num = 8;
            System.out.println(search(array, array.length, num));
        }

        public static void sort(int[] array){
            int i = 0;
            int j = 0;
            int k = 0;
            for(i = 0;i<array.length;i++){
                k = i;
                for(j = i+1;j<array.length;j++){
                    if(array[k]>array[j]){
                        k = j;
                    }
                }
                if(k!=i) {
                    int tem = array[k];
                    array[k] = array[i];
                    array[i] = tem;
                }

            }
        }
        public static void main(String[] args) {
            int[] array = {9,8,7,6,5,4,3,2,1};
            sort(array);
            System.out.println(Arrays.toString(array));
        }
    }


